﻿Imports System
Imports System.Runtime.InteropServices
Imports System.Windows.Forms

Public Class MyKeyboard

    Private Declare Function GetKeyboardState Lib "user32" Alias "GetKeyboardState" (ByVal pbKeyState() As Byte) As Long
    Private Declare Function GetKeyState Lib "USER32" Alias "GetKeyState" (ByVal ByValnVirtKey As Long) As Integer
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

    Private KeyCode As Integer

    Public Sub New(ByVal keycode As Integer)
        Me.KeyCode = keycode
    End Sub

    Public Function KeyState() As Boolean
        Return GetAsyncKeyState(KeyCode) <> 0
    End Function

End Class